package cn.yuanqiao.archive.xiaoxitongzhi.domain;

import cn.yuanqiao.common.annotation.Excel;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 消息通知对象 YQXXTZ
 * 
 * @author sy
 * @date 2023-10-10
 */
public class YqXxtz extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    private final String BIGTABLENAME = "_YQXXTZ";

    private final String GLBIGTABLENAME = "_YQXXFBFW";

    public YqXxtz() {
        String userCode = SecurityUtils.getLoginUser().getSysUser().getTenantCode();
        if(StringUtils.isEmpty(userCode)){
            throw new ServiceException("TenantCode is null");
//            this.tableName = "YQXXTZ";
//            this.glTableName = "YQXXFBFW";
        }else {
            this.tableName = userCode.toUpperCase()+BIGTABLENAME;
            this.glTableName = userCode.toUpperCase()+GLBIGTABLENAME;
        }
    }
    public YqXxtz(String tenantCode) {
        if(StringUtils.isEmpty(tenantCode)){
            throw new ServiceException("TenantCode is null");
//            this.tableName = "YQXXTZ";
//            this.glTableName = "YQXXFBFW";
        }else {
            this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
            this.glTableName = tenantCode.toUpperCase()+GLBIGTABLENAME;
        }
    }

    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    private String glTableName;

    public String getGlTableName() {
        return glTableName;
    }

    public void setGlTableName(String glTableName) {
        this.glTableName = glTableName;
    }

    /** 主键ID */
    private Long id;

    /** 消息 */
    @Excel(name = "消息")
    private String msg;

    /** 记录ID */
    @Excel(name = "记录ID")
    private Long recordId;

    /** 消息类型
     * 1:订阅类消息
     * 2:光盘台账类提醒消息
     */
    @Excel(name = "消息类型",readConverterExp="1=订阅类消息,2=其他")
    private Integer type;

    /** 是否已读
     * 0：未读
     * 1：已读
     */
    @Excel(name = "是否已读",readConverterExp="0=未读,1=已读")
    private Integer isRead;

    /** 消息接收人ID */
    @Excel(name = "消息接收人ID")
    private Long recipientsId;

    /** 消息发布人ID */
    @Excel(name = "消息发布人ID")
    private Long publisherId;


    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId()
    {
        return id;
    }
    public void setMsg(String msg)
    {
        this.msg = msg;
    }

    public String getMsg()
    {
        return msg;
    }
    public void setRecordId(Long recordId)
    {
        this.recordId = recordId;
    }

    public Long getRecordId()
    {
        return recordId;
    }
    public void setType(Integer type)
    {
        this.type = type;
    }

    public Integer getType()
    {
        return type;
    }
    public void setIsRead(Integer isRead)
    {
        this.isRead = isRead;
    }

    public Integer getIsRead()
    {
        return isRead;
    }
    public void setRecipientsId(Long recipientsId)
    {
        this.recipientsId = recipientsId;
    }

    public Long getRecipientsId()
    {
        return recipientsId;
    }
    public void setPublisherId(Long publisherId)
    {
        this.publisherId = publisherId;
    }

    public Long getPublisherId()
    {
        return publisherId;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("msg", getMsg())
                .append("recordId", getRecordId())
                .append("type", getType())
                .append("isRead", getIsRead())
                .append("remark", getRemark())
                .append("createTime", getCreateTime())
                .append("recipientsId", getRecipientsId())
                .append("publisherId", getPublisherId())
                .toString();
    }
}
